{extend name="admin@public/content"}

{block name="content"}
<form autocomplete="off" onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post"
      class='form-horizontal layui-form padding-top-20'>

    <div class="form-group">
        <label class="col-sm-1 control-label">
            抽奖名称
        </label>
        <div class='col-sm-8'>
            <input name="title" required="required" title="请输入抽奖名称" placeholder="请输入抽奖名称" value="{$vo.title}"
                   class="layui-input">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label">
            奖品设置
        </label>
        <div class='col-sm-8'>
            <p class="help-block">中奖比例:比如预计10000人，未中奖占10%，就填写1000</p>
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label">
            一等奖奖品
        </label>
        <div class='col-sm-2'>
            <input type="text" name="first" required="required" placeholder="一等奖奖品" value="{$vo.first}"
                   class="layui-input">
        </div>
        <label class="col-sm-1 control-label">
            一等奖数量
        </label>
        <div class='col-sm-1'>
            <input type="number" name="firstnums" required="required" placeholder="一等奖数量" value="{$vo.firstnums}"
                   class="layui-input">
        </div>
        <label class="col-sm-1 control-label">
            一等奖中奖比例
        </label>
        <div class='col-sm-1'>
            <input type="number" name="firstrate" required="required" placeholder="一等奖中奖比例" value="{$vo.firstrate}"
                   class="layui-input">
        </div>
        <label class="col-sm-1 control-label">
            日发放量
        </label>
        <div class='col-sm-1'>
            <input type="number" name="firstdaynums" required="required" placeholder="一等奖日发放量" value="{$vo.firstdaynums}"
                   class="layui-input">
        </div>
        <p class="help-block">今日已发{$vo.day_count1}个</p>
    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label">
            二等奖奖品
        </label>
        <div class='col-sm-2'>
            <input name="second" required="required" placeholder="二等奖奖品" value="{$vo.second}" class="layui-input">
        </div>

        <label class="col-sm-1 control-label">
            二等奖数量
        </label>
        <div class='col-sm-1'>
            <input name="secondnums" required="required" placeholder="二等奖数量" value="{$vo.secondnums}"
                   class="layui-input">
        </div>
        <label class="col-sm-1 control-label">
            二等奖中奖比例
        </label>
        <div class='col-sm-1'>
            <input type="number" name="secondrate" required="required" placeholder="二等奖中奖比例" value="{$vo.secondrate}"
                   class="layui-input">
        </div>
        <label class="col-sm-1 control-label">
            日发放量
        </label>
        <div class='col-sm-1'>
            <input type="number" name="seconddaynums" required="required" placeholder="二等奖日发放量" value="{$vo.seconddaynums}"
                   class="layui-input">
        </div>
        <p class="help-block">今日已发{$vo.day_count2}个</p>
    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label">
            三等奖奖品
        </label>
        <div class='col-sm-2'>
            <input name="third" required="required" placeholder="三等奖奖品" value="{$vo.third}" class="layui-input">
        </div>

        <label class="col-sm-1 control-label">
            三等奖数量
        </label>
        <div class='col-sm-1'>
            <input name="thirdnums" required="required" placeholder="三等奖数量" value="{$vo.thirdnums}" class="layui-input">
        </div>
        <label class="col-sm-1 control-label">
            三等奖中奖比例
        </label>
        <div class='col-sm-1'>
            <input type="number" name="thirdrate" required="required" placeholder="三等奖中奖比例" value="{$vo.thirdrate}"
                   class="layui-input">
        </div>
        <label class="col-sm-1 control-label">
            日发放量
        </label>
        <div class='col-sm-1'>
            <input type="number" name="thirddaynums" required="required" placeholder="三等奖日发放量" value="{$vo.thirddaynums}"
                   class="layui-input">
        </div>
        <p class="help-block">今日已发{$vo.day_count3}个</p>
    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label">
            四等奖奖品
        </label>
        <div class='col-sm-2'>
            <input name="four" placeholder="四等奖奖品" value="{$vo.four}" class="layui-input">
        </div>

        <label class="col-sm-1 control-label">
            四等奖数量
        </label>
        <div class='col-sm-1'>
            <input name="fournums" placeholder="四等奖数量" value="{$vo.fournums}" class="layui-input">
        </div>
        <label class="col-sm-1 control-label">
            四等奖中奖比例
        </label>
        <div class='col-sm-1'>
            <input type="number" name="fourrate" required="required" placeholder="四等奖中奖比例" value="{$vo.fourrate}"
                   class="layui-input">
        </div>
        <label class="col-sm-1 control-label">
            日发放量
        </label>
        <div class='col-sm-1'>
            <input type="number" name="fourdaynums" required="required" placeholder="四等奖日发放量" value="{$vo.fourdaynums}"
                   class="layui-input">
        </div>
        <p class="help-block">今日已发{$vo.day_count4}个</p>
    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label">
            未中奖
        </label>
        <div class='col-sm-2'>
            <input placeholder="谢谢参与" disabled="" class="layui-input layui-bg-gray">
        </div>
        <label class="col-sm-1 control-label">
            未中奖数量
        </label>
        <div class='col-sm-1'>
            <input name="nonums" required="required" placeholder="未中奖数量" value="{$vo.nonums}" class="layui-input">
        </div>
        <label class="col-sm-1 control-label">
            未中奖比例
        </label>
        <div class='col-sm-1'>
            <input type="number" name="norate" required="required" placeholder="未中奖比例" value="{$vo.norate}"
                   class="layui-input">
        </div>
        <label class="col-sm-1 control-label">
            日发放量
        </label>
        <div class='col-sm-1'>
            <input placeholder="不设限" disabled="" class="layui-input layui-bg-gray">
        </div>

    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label">
            抽奖开关
        </label>
        <div class='col-sm-8'>
            <label class="think-radio">
                <input type="radio" name="status" value="1" title="抽奖开启" {if $vo.status==1}checked=""{/if} lay-ignore> 抽奖开启
            </label>
            <label class="think-radio">
                <input type="radio" name="status" value="0" title="抽奖停止" {if $vo.status==0}checked=""{/if} lay-ignore> 抽奖停止
            </label>
            <p class="help-block">抽奖总开关</p>
        </div>
    </div>

    <div class="form-group">
       <label class="col-sm-1 control-label">兑奖须知</label>
       <div class='col-sm-8'>
           <textarea name="info">{$vo.info|default=''|htmlspecialchars_decode}</textarea>
       </div>
   </div>

    <!--<div class="form-group" data-status-type="1">
        <label class="col-sm-1 control-label">
            抽奖开始时间
        </label>
        <div class='col-sm-2'>
            <input name="statdate" id='statdate' required="required" title="请输入开始时间" placeholder="请输入开始时间"
                   value="{:date('Y-m-d H:i:s',$vo.statdate)}" class="layui-input">
        </div>

        <label class="col-sm-1 control-label">
            抽奖结束时间
        </label>
        <div class='col-sm-2'>
            <input name="enddate" id='enddate' required="required" title="请输入结束时间" placeholder="请输入结束时间"
                   value="{:date('Y-m-d H:i:s',$vo.enddate)}" class="layui-input">
        </div>
    </div>-->

    <div class="hr-line-dashed"></div>

    <div class="col-sm-4 col-sm-offset-2">
        <div class="layui-form-item text-center">
            <button class="layui-btn" type="submit">保存配置</button>
        </div>
    </div>

</form>
<script>

    window.laydate.render({
        range: false,
        type: 'datetime',
        elem: '#statdate'
    });

    window.laydate.render({
        range: false,
        type: 'datetime',
        elem: '#enddate'
    });
</script>

<script>
    (function () {
        buildStatusForm('{$vo.status}');
        $('[name=status]').on('click', function () {
            buildStatusForm($('[name=status]:checked').val())
        });

        // 表单显示编译
        function buildStatusForm(value) {
            var $tips = $("[data-status-type='" + value + "']");
            $("[data-status-type]").not($tips.show()).hide();
        }
    })();
</script>

<script>
    require(['jquery', 'ckeditor', 'angular'], function () {
        window.form.render();
        window.createEditor('[name="info"]', {height: 500});
        var app = angular.module("ProductForm", []).run(callback);
        angular.bootstrap(document.getElementById(app.name), [app.name]);

        function callback($rootScope) {
            // 单图片上传处理
            $('#ProductForm [name="pic"]').uploadOneImage();
            // 多图片上传处理
            $('#ProductForm [name="image"]').uploadMultipleImage();

        }
    });
</script>
{/block}